#pragma once

#include <map>

#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/asio.hpp>
#include <boost/function.hpp>

namespace cm {
	namespace client_server {
		namespace verbs {

enum {verb_length = 10};

static const char* check_version				= "MyVersion:";	// NON SI PUO' CAMBIARE
static const char* login						= "Login    :";
static const char* login_reply					= "LoginRply:";
static const char* message						= "Message  :";
static const char* keep_alive_from_server		= "KAFS     :";
static const char* keep_alive_from_server_reply = "KAFSReply:";
static const char* keep_alive_from_client		= "KAFC     :";
static const char* keep_alive_from_client_reply = "KAFCReply:";
static const char* on_connect					= "OnConnect:";
static const char* on_connect_reply				= "OnConnRpy:";
static const char* add_room						= "AddRoom  :";
static const char* get_rooms_props				= "GRoomsPrs:";
static const char* get_rooms_props_reply		= "GRsPrsRpy:";
static const char* join_room					= "JoinRoom :";
static const char* adv_file_dispatch			= "AdvFileDp:";
static const char* adv_file_dispatch2			= "AdvFileD2:";

//----------------------------------------------------------------------

template<typename Participant,typename Participant_ptr>
class verbs_handler
{
public:
	verbs_handler()
	{
	}
public:
	void add_handle(const char* verb,boost::function<void(Participant_ptr)> handle)
	{
		handler_via_verb_[std::string(verb)] = handle;
	}
public:
	bool handle(const std::string& verb,Participant_ptr current_participant)
	{
		if (handler_via_verb_.find(verb) == handler_via_verb_.end())
			return false;
		handler_via_verb_[verb](current_participant);
		return true;
	}
private:
	std::map<std::string,boost::function<void(Participant_ptr)> >	handler_via_verb_;
};
}}}
